/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ejb.endpointwebsocket.encoder;

import java.io.StringWriter;
import javax.json.Json;
import javax.json.stream.JsonGenerator;
import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;
import org.ejb.endpointwebsocket.util.SigEscenario;

/**
 *
 * @author MoisesAntonio
 */
public class EncSigEscenario implements Encoder.Text<SigEscenario>
{

    @Override
    public String encode(SigEscenario object) throws EncodeException {
        StringWriter swriter = new StringWriter();
        try (JsonGenerator jsonGen = Json.createGenerator(swriter)) {
            jsonGen.writeStartObject()
                .write("escenario", object.getN())
            .writeEnd();
        }
        
        return swriter.toString();
    }

    @Override
    public void init(EndpointConfig config) {    }

    @Override
    public void destroy() {    }
    
}
